# Contributor: psykose <alice@ayaya.dev>
# Maintainer: psykose <alice@ayaya.dev>
pkgname=rapidyaml
pkgver=0.4.1
pkgrel=1
_c4core=d35c7c9bf370134595699d791e6ff8db018ddc8d
_cmake=371982300ff5a076d7c3199057ebed77bbe3472f
_fast_float=32d21dcecb404514f94fb58660b8029a4673c2c1
_debugbreak=5dcbe41d2bd4712c8014aa7e843723ad7b40fd74
pkgdesc="Library to parse and emit YAML, and do it fast"
url="https://github.com/biojppm/rapidyaml/"
arch="all !s390x !riscv64" # unknown cpu arch
license="MIT"
options="!check" # needs another 3 vendored deps it git clones..
makedepends="
	cmake
	py3-cmake-build-extension
	py3-setuptools-git
	py3-setuptools_scm
	python3-dev
	samurai
	swig
	"
subpackages="$pkgname-dev py3-$pkgname:_py3"
source="$pkgname-$pkgver.tar.gz::https://github.com/biojppm/rapidyaml/archive/refs/tags/v$pkgver.tar.gz
	c4core-$_c4core.tar.gz::https://github.com/biojppm/c4core/archive/$_c4core.tar.gz
	cmake-$_cmake.tar.gz::https://github.com/biojppm/cmake/archive/$_cmake.tar.gz
	fast_float-$_fast_float.tar.gz::https://github.com/fastfloat/fast_float/archive/$_fast_float.tar.gz
	debugbreal-$_debugbreak.tar.gz::https://github.com/biojppm/debugbreak/archive/$_debugbreak.tar.gz
	"

prepare() {
	default_prepare

	rmdir "$builddir"/ext/c4core
	ln -sfv "$srcdir"/c4core-$_c4core "$builddir"/ext/c4core

	rmdir "$builddir"/ext/c4core/cmake
	ln -sfv "$srcdir"/cmake-$_cmake "$builddir"/ext/c4core/cmake

	rmdir "$builddir"/ext/c4core/src/c4/ext/debugbreak
	rmdir "$builddir"/ext/c4core/src/c4/ext/fast_float
	ln -sfv "$srcdir"/debugbreak-$_debugbreak \
		"$builddir"/ext/c4core/src/c4/ext/debugbreak
	ln -sfv "$srcdir"/fast_float-$_fast_float \
		"$builddir"/ext/c4core/src/c4/ext/fast_float
}

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=ON \
		-DRYML_BUILD_API=ON
	cmake --build build
	python3 setup.py build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	python3 setup.py install --root="$pkgdir" --skip-build

	cd "$pkgdir"/usr
	rm _ryml.so
	rm ryml.py
}

_py3() {
	pkgdesc="$pkgdesc (python bindings)"

	amove usr/lib/python3*
}

sha512sums="
a8132a1b31e7aed5883214483ccf25a2994a2336cc6f52c06e93e5aa8f9cfc059a2c1bb2bef06ca7daea2c3226c107e312c90d5d5bfd53d354598a6961aa4eb9  rapidyaml-0.4.1.tar.gz
46c2b14dcb3dd50f933afef0cc94ab4c35c8cfa9c82789774fee4004d97f4dbb13665410b3e54041efb6ac46ef24b871af5fbaab9067e24e6ef2993bf73e95c8  c4core-d35c7c9bf370134595699d791e6ff8db018ddc8d.tar.gz
81d4bf158ef0eb1710d97db523f9ed276de1df78bb3597d0d10046ea41a3bbc7a30fc2f78f19a0a18863ff4cda65cda99edc035a714fd52fe0cadef167daac8f  cmake-371982300ff5a076d7c3199057ebed77bbe3472f.tar.gz
2cbdc5b05ab7c19e20b4e34959b90d1fa866d4ba239ec0a4c434cd33bddfb1cb6f1da467b0a525f5a4887c9b1860e975fe074aca0d9e211f0fc7bc6402d3601e  fast_float-32d21dcecb404514f94fb58660b8029a4673c2c1.tar.gz
8c63cbab94c049d6f04a48b9de73f22c50ed1e68eba2b77a0fdcb63952d88b1f7248c59e3f4d519c1211a93f378c0200f62fae5a2596a1decd5df18204d4f488  debugbreal-5dcbe41d2bd4712c8014aa7e843723ad7b40fd74.tar.gz
"
